<template>
	<view class="corrigendum ff-font-14 ff-color-000">
		<view class="ff-bg-fff ff-margin-12 ff-border-radius-10 ff-padding-10">
			<view class="ff-flex-between ff-relative">
				<view class="corrigendum-content-title ff-font-16 ff-font-weight-600 ff-border-radius-5">单位信息</view>
				<view class="corrigendum-content-button" @click="corrigendumInfoClick">信息勘误</view>
			</view>
			<view class="corrigendum-content-info ff-margin-top-15 ff-line-height-1-3">
				<view class="corrigendum-content-info-box">
					<view class="ff-flex ff-padding-left-5 ff-margin-bottom-16">
						<view class="corrigendum-content-info-box-left">社会单位</view>
						<view>{{ assessDetails.companyName }}</view>
					</view>
					<view class="ff-flex ff-padding-left-5 ff-margin-bottom-16">
						<view class="corrigendum-content-info-box-left">评估地址</view>
						<view class="ff-flex-1">{{ assessDetails.assessAddr }}</view>
					</view>
					<view class="ff-flex ff-padding-left-5 ff-margin-bottom-16">
						<view class="corrigendum-content-info-box-left">项目类型</view>
						<view>{{ assessDetails.assessProjectTypeName }}</view>
					</view>
					<view class="ff-flex ff-padding-left-5 ff-margin-bottom-16">
						<view class="corrigendum-content-info-box-left">建筑面积(m²)</view>
						<view>{{ assessDetails.assessProjectArea }}</view>
					</view>
					<view class="ff-padding-left-5">
						<view class="corrigendum-content-info-box-left ff-margin-bottom-10">主要消防设施</view>
						<view class="ff-padding-left-4">
							<view class="ff-flex-wrap">
								<view class="ff-margin-right-10 ff-margin-bottom-10"
									v-for="(item, index) of assessDetails.facilities" :key="index">
									<u-tag :text="`${index + 1}.${item.facilitiesTypeName}`" />
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>

		<view class="corrigendum-butList"><u-button type="primary" shape="circle"
				@click="corrigendumSumbit">确认</u-button></view>
		<!-- 弹窗区 -->
		<u-toast ref="uToast" />
		<f-loading ref="loading" />
		<u-modal v-model="corrigendumModel" @confirm="corrigendumConfirm" title="温馨提示" show-cancel-button="true"
			:content-style="{ 'line-height': '1.5' }" :content="corrigendumContent" />
		<u-back-top :scrollTop="scrollTopList.scrollTop" top="200" mode="circle" :iconStyle="scrollTopList.iconStyle"
			:customStyle="scrollTopList.customstyle"></u-back-top>
	</view>
</template>

<script>
	export default {
		name: 'Corrigendum',
		data() {
			return {
				corrigendumModel: false, // 勘误提示弹窗显/隐
				corrigendumContent: '', // 刊物弹窗具体内容
				// 返回顶部组件参数
				scrollTopList: {
					scrollTop: 0,
					iconStyle: {
						fontSize: '32rpx',
						color: '#FFFFFF'
					},
					customstyle: {
						background: '#3B83FE'
					}
				},
				assessId: {}, // 前边页面传过来的数据（评估id)
				assessDetails: {} // 评估项目详情数据
			};
		},
		onPageScroll(e) {
			this.scrollTopList.scrollTop = e.scrollTop;
		},
		onShow() {
			this.getAssessDetails(); // 获取建筑物详情页数据
		},
		onLoad(e) {
			// console.log('前页面传过来的数据------', e);
			this.assessId = e.assessId;
			this.getAssessDetails(); // 获取建筑物详情页数据
		},
		methods: {
			// 获取评估项目详情页数据
			async getAssessDetails() {
				this.$refs.loading.openLoading('加载中···'); // 打开loading动画
				const data = await this.$http.post({
					url: '/bsAssessProjectInfo/detail',
					data: {
						assessId: this.assessId
					}
				});
				// console.log('获取评估项目详情页数据-----', data);
				if (data.code == 200) {
					this.assessDetails = data.data;
				}
				this.$refs.loading.closeLoading(); // 关闭loading动画
			},
			// 点击去勘误建筑物-------操作
			corrigendumInfoClick() {
				this.$pageJump.navigateTo(
					'/pages/assessment/mechanism/home/components/corrigendum/components/corrigendumInfo?assessId=' +
					this.assessDetails.assessId);
			},
			// 勘误--------提交
			corrigendumSumbit() {
				this.corrigendumContent = '每个项目只有一次信息勘误的机会，请确认是否正确？';
				this.corrigendumModel = true;
			},
			// 勘误-------确认操作
			corrigendumConfirm() {
				let that = this;
				that.$refs.loading.openLoading('提交中···'); // 打开loading动画
				that.$http.get({
					url: `/bsAssessProjectInfo/${that.assessDetails.assessId}/confirm`
				}).then(res => {
					// console.log('勘误-------确认操作返回的结果', res);
					that.$refs.loading.closeLoading(); // 关闭loading动画
					if (res.code == 200) {
						that.$refs.uToast.show({
							title: '保存成功',
							type: 'success'
						});
						setTimeout(() => {
							// 跳转到指派的页面
							that.$pageJump.redirectTo(
								'/pages/assessment/mechanism/home/components/assign/Assign?assessId=' +
								that.assessDetails.assessId + '&type=' + 1);
						}, 500);
					} else {
						that.$refs.uToast.show({
							title: res.msg,
							type: 'error'
						});
					}
				});
			}
		},
		onShareAppMessage() {
			return {
				title: '分享小程序给朋友',
				path: '/pages/homePage/Home'
			};
		}
	};
</script>

<style lang="scss">
	.corrigendum {
		.u-size-default {
			height: auto !important;
		}
	}
</style>
<style lang="scss" scoped>
	.corrigendum {
		&-header {
			margin: 32rpx 24rpx;
		}

		&-content {
			&-button {
				position: absolute;
				right: 0;
				line-height: 1;
				background-color: #f5f8ff;
				border: 2rpx solid #3178ff;
				color: #3178ff;
				padding: 18rpx 22rpx;
				border-radius: 12rpx;
				display: inline-block;
			}

			&-title {
				background: linear-gradient(to right, #eeeeee, #f9f9f9);
				padding: 24rpx 20rpx 20rpx;
				width: 100%;
			}

			&-info {
				&-box {
					&-left {
						width: 28%;
						margin-right: 37rpx;
						color: #a6a6a6;
					}

					&-right {
						width: 64%;
					}
				}
			}

			&-table {
				&-box {
					margin-bottom: 50rpx;

					.ff-flex {
						padding: 24rpx 58rpx;

						.table-left-title {
							width: 70%;
							margin-right: 10%;
						}

						.table-left {
							width: 70%;
							margin-right: 10%;
							color: #5c5f65;
						}

						.table-right {
							flex: 1;
						}
					}
				}
			}

			&-table .ff-flex:nth-child(odd) {
				background-color: #f8f8f8;
			}
		}

		&-butList {
			margin: 0 5%;
			padding: 60rpx 0 100rpx;
			width: 90%;

			/deep/.u-size-default {
				height: 90rpx !important;
				line-height: 90rpx !important;
			}
		}
	}

	.corrigendum-tableBox:last-child .corrigendum-table-box {
		margin-bottom: 0;
	}
</style>